package com.ruyuan.engine.datagen;
import com.ruyuan.engine.pojo.RuleComplexParam;
import com.ruyuan.engine.pojo.RuleEventExecuteParam;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 生成动态条件
 * */
public class RuleComplexParamDataGen {
    public static RuleComplexParam mockData() {
        RuleComplexParam ruleComplexParam = new RuleComplexParam();
        ruleComplexParam.setRuleId("100001");
        ruleComplexParam.setRuleName("RuleConditionTest");

        //构造触发条件
        RuleEventExecuteParam trigger = new RuleEventExecuteParam();
        trigger.setEventId("M");
        ruleComplexParam.setTrigger(trigger);

        //1. 动态匹配用户的基本行为条件，交易次数，下单次数
        HashMap<String,String> baseRuleParams = new HashMap<>();
        baseRuleParams.put("tagCondition1","tagValue1");
        baseRuleParams.put("tagCondition2","tagValue2");
        ruleComplexParam.setBaseRuleParams(baseRuleParams);

        //2. 组合规则
        ArrayList<RuleEventExecuteParam> combinationRuleParams = new ArrayList<RuleEventExecuteParam>();

        //组合规则1
        RuleEventExecuteParam ruleEventExecuteParam1 = new RuleEventExecuteParam();
        ruleEventExecuteParam1.setEventId("M");
        HashMap<String,String> ruleEventCombination1 = new HashMap<>();
        ruleEventCombination1.put("tagCondition1","tagValue1");
        ruleEventCombination1.put("tagCondition2","tagValue2");
        ruleEventExecuteParam1.setProperties(ruleEventCombination1);
        //该规则需要满足的次数
        ruleEventExecuteParam1.setThreshold(2);

        //组合规则2
        RuleEventExecuteParam ruleEventExecuteParam2 = new RuleEventExecuteParam();
        ruleEventExecuteParam2.setEventId("M");
        HashMap<String,String> ruleEventCombination2 = new HashMap<>();
        ruleEventCombination2.put("tagCondition1","tagValue1");
        ruleEventCombination2.put("tagCondition2","tagValue2");
        ruleEventExecuteParam2.setProperties(ruleEventCombination2);
        ruleEventExecuteParam2.setThreshold(2);

        combinationRuleParams.add(ruleEventExecuteParam1);
        combinationRuleParams.add(ruleEventExecuteParam2);
        ruleComplexParam.setCombinationRuleParams(combinationRuleParams);

        //3. 顺序组合规则
        List<RuleEventExecuteParam> sequenceRuleParams = new ArrayList<RuleEventExecuteParam>();
        //顺序规则1
        RuleEventExecuteParam sequenceRuleParams1 = new RuleEventExecuteParam();
        sequenceRuleParams1.setEventId("A");
        HashMap<String,String> sequenceRuleParamsMap1 = new HashMap<>();
        sequenceRuleParamsMap1.put("tagCondition1","tagValue1");
        sequenceRuleParamsMap1.put("tagCondition2","tagValue2");
        sequenceRuleParams1.setProperties(sequenceRuleParamsMap1);

        //顺序规则2
        RuleEventExecuteParam sequenceRuleParams2 = new RuleEventExecuteParam();
        sequenceRuleParams2.setEventId("C");
        HashMap<String,String> sequenceRuleParamsMap2 = new HashMap<>();
        sequenceRuleParamsMap2.put("tagCondition1","tagValue1");
        sequenceRuleParamsMap2.put("tagCondition2","tagValue2");
        sequenceRuleParams2.setProperties(sequenceRuleParamsMap2);

        //顺序规则3
        RuleEventExecuteParam sequenceRuleParams3 = new RuleEventExecuteParam();
        sequenceRuleParams3.setEventId("S");
        HashMap<String,String> sequenceRuleParamsMap3 = new HashMap<>();
        sequenceRuleParamsMap3.put("tagCondition1","tagValue1");
        sequenceRuleParamsMap3.put("tagCondition2","tagValue2");
        sequenceRuleParams3.setProperties(sequenceRuleParamsMap3);

        sequenceRuleParams.add(sequenceRuleParams1);
        sequenceRuleParams.add(sequenceRuleParams2);
        sequenceRuleParams.add(sequenceRuleParams3);
        ruleComplexParam.setSequenceRuleParams(sequenceRuleParams);
        return ruleComplexParam;
    }
}
